package queue;

import java.util.Scanner;

public class ArrayQueueTest {
    public static void main(String[] args) {

     boolean flag = true;
        ArrayQueue queue = new ArrayQueue(3);
        Scanner sc = new Scanner(System.in);
        while(flag){
            System.out.println("e.enqueue d.dequeue p.printQueue h.peek" + " q.quit");
            System.out.println("Enter an option: ");
            int option = sc.next().charAt(0);
            switch(option){
                case 'p':
                    queue.printQueue();
                    break;
                case 'e':
                    System.out.println("Enter an element: ");
                    int value = sc.nextInt();
                    queue.enqueue(value);
                    break;
                case 'd':
                    try{
                        int val = queue.dequeue();
                        System.out.println(val);
                        break;
                    }catch(Exception e){
                        System.out.println(e.getMessage());
                    }
                case 'h':
                    try{
                        int val = queue.peek();
                        System.out.println(val);
                        break;
                    }catch(Exception e){
                        System.out.println(e.getMessage());

                    }
                case 'q':
                    flag = false;
                    break;
                default:
                    System.out.println("Invalid option");
                    break;
            }

        }
    }
}
